﻿Imports Microsoft.VisualBasic
Imports ControladorasAT.SIREOS
Imports ServiciosAT
Imports System.Data

Public Class Listas

    Shared Sub listarTabla(cab As Integer, ddlb As DropDownList)
        Dim oTablaDetalleBE As New SireosWSComun.TablaDetalle
        oTablaDetalleBE.codCabecera = cab
        Dim oCtGeneral As New CtComun
        Dim dt As DataTable = oCtGeneral.listarTablaDetalle(oTablaDetalleBE)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomDetalle"
                .DataValueField = "CodDetalle"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarAreas(ddlb As DropDownList)
        Dim oCtAreas As New CtComun
        Dim dt As DataTable = oCtAreas.listarAreas()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomArea"
                .DataValueField = "CodArea"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarCargos(ddlb As DropDownList)
        Dim oCtCargos As New CtComun
        Dim dt As DataTable = oCtCargos.listarCargos()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomCargo"
                .DataValueField = "CodCargo"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub ListarContactosSedes(codSede As Integer, ddlb As DropDownList)
        Dim oSede As New SireosWSCliente.Sede
        oSede.codSede = codSede

        Dim oCtCliente As New CtCliente
        Dim dt As DataTable = oCtCliente.listarContactosSede(oSede)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "Contacto"
                .DataValueField = "CodContacto"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarDistritos(ddlb As DropDownList, codDepartamento As String, codProvincia As String)
        Dim oUbigeo As New SireosWSComun.Ubigeo
        oUbigeo.codDepartamento = codDepartamento
        oUbigeo.codProvincia = codProvincia

        Dim oCtUbigeo As New CtComun
        Dim dt As DataTable = oCtUbigeo.listarDistritos(oUbigeo)
        With ddlb
            .Items.Clear()
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscUbigeo"
                .DataValueField = "CodUbigeo"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarFallas(ddlb As DropDownList)
        Dim oCtEquipo As New CtComun
        Dim dt As DataTable = oCtEquipo.listarFallas
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscFalla"
                .DataValueField = "CodFalla"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarFamilias(ddlb As DropDownList)
        Dim oCtEquipo As New CtComun
        Dim dt As DataTable = oCtEquipo.listarFamilias()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomFamilia"
                .DataValueField = "CodFamilia"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarGarantias(codTipoServicio As Integer, ddlb As DropDownList)
        Dim oCtGarantia As New CtComun
        Dim dt As DataTable = oCtGarantia.listarGarantias(codTipoServicio)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscGarantia"
                .DataValueField = "CodGarantia"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarLocales(ddlb As DropDownList)
        Dim oCtLocales As New CtComun
        Dim dt As DataTable = oCtLocales.listarLocales()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomLocal"
                .DataValueField = "CodLocal"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarMarcasEquipo(ddlb As DropDownList)
        Dim oCtEquipo As New CtComun
        Dim dt As DataTable = oCtEquipo.listarMarcasEquipo()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomMarca"
                .DataValueField = "CodMarca"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarMarcasTipoEquipo(ddlb As DropDownList, codTipoEquipo As Integer)
        Dim oTipoEquipoBE As New SireosWSEquipo.TipoEquipo
        oTipoEquipoBE.codTipoEquipo = codTipoEquipo

        Dim oCtEquipo As New CtEquipo
        Dim dt As DataTable = oCtEquipo.listarMarcas(oTipoEquipoBE)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomMarca"
                .DataValueField = "CodMarca"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarModelos(ddlb As DropDownList, codTipoEquipo As Integer, codMarca As Integer)
        Dim oModeloBE As New SireosWSEquipo.Modelo
        oModeloBE.codTipoEquipo = codTipoEquipo
        oModeloBE.codMarca = codMarca

        Dim oCtEquipo As New CtEquipo
        Dim dt As DataTable = oCtEquipo.listarModelos(oModeloBE)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscModelo"
                .DataValueField = "CodModelo"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarPrioridad(ddlb As DropDownList)
        Dim oCtPrioridad As New CtComun
        Dim dt As DataTable = oCtPrioridad.listarPrioridad()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomPrioridad"
                .DataValueField = "CodPrioridad"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub ListarProvincias(ddlb As DropDownList, codDepartamento As String)
        Dim oUbigeoBE As New SireosWSComun.Ubigeo
        oUbigeoBE.codDepartamento = codDepartamento

        Dim oCtUbigeo As New CtComun
        Dim dt As DataTable = oCtUbigeo.listarProvincias(oUbigeoBE)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscUbigeo"
                .DataValueField = "CodProvincia"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarProyecto(ddlb As DropDownList)
        Dim oCtProyecto As New CtComun
        Dim dt As DataTable = oCtProyecto.listarProyecto
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "NomProyecto"
                .DataValueField = "CodProyecto"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarRegiones(ddlb As DropDownList)
        Dim oCtUbigeo As New CtComun
        Dim dt As DataTable = oCtUbigeo.listarRegiones
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscUbigeo"
                .DataValueField = "CodDepartamento"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarSedeCliente(codcliente As Integer, ddlb As DropDownList)
        Dim oClienteBE As New SireosWSCliente.Cliente
        oClienteBE.codCliente = codcliente

        Dim oCtCliente As New CtCliente
        Dim dt As DataTable = oCtCliente.listarSedeCliente(oClienteBE)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "Sede"
                .DataValueField = "CodSede"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarTienda(ddlb As DropDownList)
        Dim oCtCliente As New CtCliente
        Dim dt As DataTable = oCtCliente.listarTienda()
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "RazonSocial"
                .DataValueField = "CodCliente"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarTipoEquipo(codfamilia As Integer, ddlb As DropDownList)
        Dim oFamilia As New SireosWSComun.Familia
        oFamilia.codFamilia = codfamilia

        Dim oCtEquipo As New CtComun
        Dim dt As DataTable = oCtEquipo.listarTipoEquipo(oFamilia)
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "DscTipoEquipo"
                .DataValueField = "CodTipoEquipo"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub

    Shared Sub listarVendedores(ddlb As DropDownList)
        Dim oCtServicio As New CtComun
        Dim dt As DataTable = oCtServicio.listarVendedores
        With ddlb
            .Items.Clear()
            .DataSource = dt
            If Not (dt Is Nothing) Then
                .DataTextField = "Vendedor"
                .DataValueField = "CodEmpleado"
            End If
            .DataBind()
            .Items.Insert(0, New ListItem("-- Seleccione --", 0))
        End With
    End Sub


End Class
